import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
        // This makes the visual density adapt to the platform that you run
        // the app on. For desktop platforms, the controls will be smaller and
        // closer together (more dense) than on mobile platforms.
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: HomePage(),
      debugShowCheckedModeBanner: false,
    );
  }
}

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            textDirection: TextDirection.rtl,
            children: [_getWords()],
          )),
    );
  }

  Widget _getWords() {
    // const text =
    //     "That's all 😉🐐 12345 One Two Three Four Five ᠸᠢᠺᠢᠫᠧᠳᠢᠶᠠ᠂ ᠴᠢᠯᠦᠭᠡᠲᠦ ᠨᠡᠪᠲᠡᠷᠬᠡᠢ ᠲᠣᠯᠢ ᠪᠢᠴᠢᠭ ᠪᠣᠯᠠᠢ᠃";
    const text =
        "曾经沧海难为水,除却巫山不是云;取次花丛懒回顾,半缘修道半缘君哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈啊哈哈哈哈哈哈啊哈哈啊哈哈哈哈哈哈哈哈哈哈哈哈哈哈";
    //var emoji = RegExp(r"([\u2200-\u3300]|[\uD83C-\uD83E].)");
    List<Widget> left = [];
    var words = text.split("");
    List<Widget> right = [];
    for (var word in words) {
      if (word == ";") {
        left = right;
        right = [];
        continue;
      }
      right.add(RotatedBox(
          quarterTurns: 4,
          child: Text(
            word,
            style: TextStyle(fontSize: 22),
          )));
      right.add(SizedBox(
        height: 4,
      ));
    }
    return Container(
        height: 200,
        padding: EdgeInsets.all(20),
        child: ListView(
          scrollDirection: Axis.horizontal,
          reverse: true,
          children: [
            Row(
              textDirection: TextDirection.rtl,
              children: [
                Wrap(
                  textDirection: TextDirection.rtl,
                  direction: Axis.vertical,
                  children: left,
                ),
                SizedBox(
                  width: 22,
                ),
                Wrap(
                  textDirection: TextDirection.rtl,
                  direction: Axis.vertical,
                  children: right,
                )
              ],
            ),
          ],
        ));
  }
}
